package de.iceboy.android.goldrush.data;

import android.util.Log;
import de.iceboy.android.goldrush.view.TargetView;

public class HitPoint {
	private int x;
	private int y;

	public HitPoint(int xpos, int ypos) {
		x = makeValid(xpos);
		y = makeValid(ypos);		
		Log.d("Point", x + ", " + y);
	}
	private int makeValid(int pos) {
		return Math.min(TargetView.UPPDER_BOUND, Math.max(pos, TargetView.LOWER_BOUND));
	}
	
	public double getDistanceToCenter(){
		return Math.sqrt((x-TargetView.CENTER)*(x-TargetView.CENTER) + (y-TargetView.CENTER)*(y-TargetView.CENTER));
	}
	
	public int getValue(){
		double distance = getDistanceToCenter();
		Log.d("distance", distance + "");
		return TargetView.RINGS - ((int)(getDistanceToCenter()/(TargetView.UPPDER_BOUND/(2*TargetView.RINGS))));
	}
	
	public boolean isXRing(){
		return getDistanceToCenter() < TargetView.XRING_RANGE;
	}
	
	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

}
